PIC IRQ0 using PIT frequency/mode settings, sleep() and atoi() functions, sleep syscall; PIC IRQ8 for CMOS real time clock date/time values, "bool" type; Sleeping works pretty well on bochs, but it's broken or hit or miss on qemu on this OpenBSD VM. But on FreeBSD it's fine in qemu, so let's say it works :^) OS Dev playlist: https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX Source code as of the end of this video: https://git.sr.ht/~queso_fuego/amateur_os_video_sources/tree/master/item/40_irq0_irq8 These might change to git commands for checking out a specific commit, instead of taking up a whole repo and space for every video. Repos for the OS: Sourcehut: https://git.sr.ht/~queso_fuego/quesos Github mirror: https://github.com/queso-fuego/amateuros Notes: - It isn't really a big deal at the moment that the 1ms IRQ0 isn't exact, but to be correct and for later on, it should compensate for fractional values. Every 1000ms it has an extra .15 ms, so every 7000ms (7 seconds) it will gain 1.05ms. As a hacky fix, any given sleep values could be changed to subtract 1 for every ~7000ms, or something like sleep_ms -= (sleep_ms / 7000) but using better math. OS Dev wiki has better examples for dealing with fractional time in asm. - My locate database updated later, this was a pretty fresh vm. I know about updatedb now, and also that many OpenBSD headers are in /usr/include/ e.g. stdbool is at /usr/include/stdbool.h. I might have to typedef true as true and false as false for macro handling, and maybe set false = 0 explicitly in the enum, but not sure if anything else would be needed for "proper" boolean handling in C. - cmos_update_in_progress() had a bug for return (inb(cmos_data & 80)), the top bit would be 0x80, not 80! This has been fixed in the repos. Links to things: https://wiki.osdev.org/Programmable_Interval_Timer https://wiki.osdev.org/RTC https://wiki.osdev.org/CMOS https://web.archive.org/web/20121127045040/https://www.nondot.org/sabre/os/files/MiscHW/RealtimeClockFAQ.txt https://www.bioscentral.com/misc/cmosmap.htm Next video ideas: PIC IRQ1 for keyboard handling, testing square wave sounds with the PC speaker using PIT channel 2; Or something else... - Let me know if there's anything specific you'd like to see New Community Discord, there isn't much there, but come hang out sometime: https://discord.gg/yKm4T89QFn Outline: 0:00 - Changes to use nasm instead of fasm; use octal instead of hex when building filetable 8:40 - PIT info 14:11 - Set up PIT and IRQ0 39:13 - Sleep syscall and commands 55:11 - atoi() function 1:00:44 - Sleep testing/debugging; move syscall calls to time.h 1:20:10 - CMOS RTC info 1:31:07 - Set up CMOS RTC and IRQ8 2:29:58 - Wrap up & Outro Software used: VMware Workstation Player - https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html openBSD - https://www.openbsd.org/ qemu - https://www.qemu.org/ vim - https://www.vim.org/ clang - https://clang.llvm.org/ davinci resolve - https://www.blackmagicdesign.com/products/davinciresolve/ OBS Studio - https://obsproject.com/ Peripherals: Camera: Sony ZV-1, Elgato Camlink 4k Microphone: Shure SM7B, Cloudlifter CL-1, Focusrite Scarlett Solo Keyboard: HHKB Pro Hybrid Type S, white/blank keycaps Mouse: Logitech M590 Contact: email - fuegoqueso@gmail.com twitter - @Queso_Fuego twitch - https://www.twitch.tv/queso_fuego Thoughts/Notes/Suggestions/Other - Drop a message in the video comments, twitter, or email Updates for these videos and other things will be on twitter, the YouTube channel community tab, or mailing lists, if I remember. Credits: Music from https://incompetech.com: "Your Call" Kevin MacLeod (incompetech.com) Licensed under Creative Commons: By Attribution 4.0 License http://creativecommons.org/licenses/by/4.0/ #osdev #pic #interrupts